cmake_minimum_required(VERSION 3.8)
project(ai_agent_planner)

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(vehicle_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(common REQUIRED)
find_package(vehicle_model REQUIRED)
find_package(forward_simulator REQUIRED)
find_package(semantic_map_manager REQUIRED)
find_package(behavior_planner REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(OpenCV REQUIRED)

# Set third party include directories using absolute path
set(THIRD_PARTY_INCLUDE_DIRS /home/yz/Code/EPSILON/map/semantic_map_manager/thirdparty)

# Include directories
include_directories(
  ${common_INCLUDE_DIRS}
  ${semantic_map_manager_INCLUDE_DIRS}
  ${vehicle_model_INCLUDE_DIRS}
  ${forward_simulator_INCLUDE_DIRS}
  ${behavior_planner_INCLUDE_DIRS}
  ${THIRD_PARTY_INCLUDE_DIRS}
)

# Create executable
add_executable(onlane_ai_agent
    src/onlane_ai_agent.cc
)

# Add ROS2 dependencies to executable
ament_target_dependencies(onlane_ai_agent
  rclcpp
  rclcpp_components
  std_msgs
  geometry_msgs
  sensor_msgs
  visualization_msgs
  vehicle_msgs
  nav_msgs
)

# Link libraries
target_link_libraries(onlane_ai_agent
    common::hkust_pl_common
    semantic_map_manager::hkust_smm_ros
    behavior_planner::behavior_planner_ros
    vehicle_model::vehicle_model
    ${Boost_LIBRARIES}
    ${OpenCV_LIBRARIES}
)

# Install executable
install(TARGETS onlane_ai_agent
  DESTINATION lib/${PROJECT_NAME}
)

# Testing
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()